<template>
  <div>
    <el-table :data="list" border style="width: 100%">
      <!-- width="180" -->
      <el-table-column prop="aaa" label="设备名称" show-overflow-tooltip width="75">
      </el-table-column>
      <el-table-column prop="bbb" label="设备地点" show-overflow-tooltip width="75">
      </el-table-column>
      <el-table-column prop="ccc" label="故障类型" show-overflow-tooltip width="75">
      </el-table-column>
      <el-table-column prop="ddd" label="是否复核" show-overflow-tooltip width="75">
      </el-table-column>
      <el-table-column prop="eee" label="故障说明" show-overflow-tooltip width="75">
      </el-table-column>
      <el-table-column prop="fff" label="处理后图片" show-overflow-tooltip width="90">
      </el-table-column>
      <el-table-column label="操作">
        <el-link type="primary">详情</el-link>
        <el-link type="primary" class="ml5">复核</el-link>
        <el-link type="danger" class="ml5" @click="onDel(row.id)">删除</el-link>
      </el-table-column>
    </el-table>
    <div class="mt10">
      <el-button
        type="primary"
        icon="el-icon-plus"
        plain
        size="small"
        class="w-full"
        @click="showSelectDevice = true"
        >添加设备</el-button
      >
    </div>
    <select-device
      :visible.sync="showSelectDevice"
      @select="onAdd"
    ></select-device>
  </div>
</template>

<script>
import SelectDevice from "./components/select-device.vue";
export default {
  name: "TsErrorReview",
  inject: ["conf"],
  computed: {
    list() {
      return this.conf.list;
    },
  },
  props: [],
  components: {
    SelectDevice,
  },
  data() {
    return {
      showSelectDevice: false,
    };
  },
  created() {},
  mounted() {},
  methods: {
    onAdd(devices) {
      let data = devices.map((t) => ({
        id: t.id,
        aaa: t.aaa,
        bbb: t.bbb,
        ccc: t.fff,
        ddd: "是",
        eee: "",
        fff: "",
      }));
      this.list.push(...data);
    },
    async onDel(id) {
      try {
        await this.$confirm("确认删除？", "提示", { type: "warning" });
        let i = this.list.findIndex((t) => t.id === id);
        this.list.splice(i, 1);
      } catch (error) {}
    },
  },
  watch: {},
};
</script>

<style lang="scss" scoped></style>
